<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">工作日志登记表</h3>
            </div>

            <!-- BASIC FORM ELEMENTS -->
            <!--===================================================-->
            <form id="form_worklog_input" class="panel-body form-horizontal form-padding">
                <input type="hidden" name="keyId" id="keyId" value="${worklog.id}" />

                <div class="form-group div-Hidden">
                    <label class="col-md-2 control-label">时间<i class="fa fa-asterisk txt-color-red"></i></label>
                    <div class="col-md-6">
                            <div class="input-group date">
                                <input type="text" class="form-control" id="datWorklog" name="datWorklog" placeholder="请选择时间"
                                value=<fmt:formatDate pattern="yyyy-MM-dd" value="${worklog.datWorklog}" /> >
                                <span class="input-group-addon"><i class="ti-calendar"></i></span>
                            </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">日志名称<i class="fa fa-asterisk txt-color-red"></i></label>
                    <div class="col-md-6">
                        <input type="text" id="name" name="name" class="form-control" placeholder="请输入日志名称" value="${worklog.name}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">工作日志内容<i class="fa fa-asterisk txt-color-red"></i></label>
                    <div class="col-md-6">
                        <input type="text" id="content" name="content" class="form-control" placeholder="请输入工作日志内容" value="${worklog.content}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">文件附件上传</label>
                    <div class="col-md-6">
                        <input name="uploadify" id="fileAttachment" placeholder="" type="file" >
                        <input name="hiddenFiles" id="hiddenFilesAttachment" type="hidden" value="${worklog.fileAttachment}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">提交人</label>
                    <div class="col-md-2">
                        <p class="form-control-static">${worklog.creater.name}</p>
                    </div>
                    <label class="col-md-2 control-label">提交日期</label>
                    <div class="col-md-2">
                        <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${worklog.dateApply}" /></p>
                    </div>
                </div>
            </form>
            <!--===================================================-->
            <!-- END BASIC FORM ELEMENTS -->

            <div class="panel-footer">
                <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
                    <i class="fa fa-lg fa-mail-reply"></i> 返回视图
                </a>
                <c:if test="${worklog.numStatus==0 && user.id==worklog.creater.id}">
                    <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存表单 </a>
                    <a class="btn btn-warning" id="btn-submit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交表单 </a>
                </c:if>
            </div>
        </div>
    </div>
</div>

<script>

    // 日期选择
    $('.input-group.date').datepicker({
        format: 'yyyy-mm-dd',
        weekStart: 1,
        autoclose: true,
        todayBtn: 'linked',
        todayHighlight: true,
        language: 'zh-CN'
    });

    // 附件上传
    inputLoad({
        objId:"fileAttachment",
        entityName:"fileAttachment",
        sourceId:"hiddenFilesAttachment"
    });

    //校验
    function infoValidate() {
        var tmp = "";

        tmp = $("input#datWorklog").val();
        if(!tmp){
            __toastr_error("请选择时间！");
            return false;
        }

        tmp = $("input#name").val();
        if(!tmp){
            __toastr_error("请输入日志名称！");
            return false;
        }

        tmp = $("input#content").val();
        if(!tmp){
            __toastr_error("请输入工作日志内容！");
            return false;
        }

        return true;
    }

    //保存
    $("#btn-save-common").click(
            function(e) {
                __confirm_dialog("提示：","确定保存吗？",
                        function () {
                            __form_save("form_worklog_input", "<%=path%>/activiti/worklog/save");
                            returnToHashUrl();
                        }
                )
            }
    );

    //提交
    $("#btn-submit-common").click(
            function(e) {
                var $valid = infoValidate();
//                console.log("v:"+$valid);
                if(!$valid) return false;

                __confirm_dialog("提示：","提交后填写资料不得修改，请确认是否进行提交？",
                        function () {
                            __form_save("form_worklog_input", "<%=path%>/activiti/worklog/submit");
                            returnToHashUrl();
                        }
                )
            }
    );

    //返回视图
    $("#apply-re-common").click(returnToHashUrl);

    // 加载完成后执行
    $(function(){

    })

</script>




